package com.example.smartstart.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.smartstart.entity.StudentInfo;
import com.example.smartstart.entity.dto.StudentInfoDTO;
import com.example.smartstart.mapper.StudentInfoMapper;
import com.example.smartstart.service.IStudentInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

@Service
public class StudentInfoServiceImpl extends ServiceImpl<StudentInfoMapper,StudentInfo> implements IStudentInfoService {
    @Autowired
    private StudentInfoMapper studentInfoMapper;

    @Override
    public List<StudentInfo> listAllStudentInfo(){
        return studentInfoMapper.listAllStudentInfo();
    }

    @Override
    public StudentInfo getStudentInfoById(String studentId){
        return studentInfoMapper.getStudentInfoById(studentId);
    }

    @Override
    public void saveStudentInfo(List<StudentInfo> studentInfoList){
        saveBatch(studentInfoList);
    }

    @Override
    public StudentInfo register(String examinerNumber,String idNumber){
        return studentInfoMapper.findStudentInfo(examinerNumber,idNumber);
    }

    @Override
    public void updateInfo(String phone, String qqNumber, String email, String grateSchool, String origin, String address,String photo,String studentId){
        LocalDate checkInDate = LocalDate.now();
        String status = "已报到";
        studentInfoMapper.updateInfo(checkInDate,status,phone,qqNumber,email,grateSchool,origin,address,photo,studentId);
    }

    @Override
    public List<StudentInfo> listByPage(StudentInfo studentInfo){
        return studentInfoMapper.listByPage(studentInfo);
    }

    @Override
    public Integer queryTotal(StudentInfo studentInfo){
        return studentInfoMapper.queryTotal(studentInfo);
    }

    @Override
    public Integer deleteInfo(String studentId){
        return studentInfoMapper.deleteById(studentId);
    }

    @Override
    public StudentInfoDTO getStudentInfoCount() {
        return studentInfoMapper.getStudentInfoCount();
    }

    @Override
    public List<StudentInfoDTO> getClassReportCount() {
        return studentInfoMapper.getClassReportCount();
    }

    @Override
    public List<StudentInfoDTO> getCollegeStudentSCount() {
        return studentInfoMapper.getCollegeStudentSCount();
    }

    @Override
    public List<StudentInfoDTO> getDepartmentStudentSCount() {
        return studentInfoMapper.getDepartmentStudentSCount();
    }
}
